/* http://alvinalexander.com/ooa-ood/java-model-view-controller-mvc-example-2
 * When the employee works in the "Order" tab of the application, 
 * the OrderController handles the interactions with the employee,
 * displaying dialogs, working with other controllers, and updating Order-related data. * 
 */
package Controller;

import Dao.OrderDao;
import Main.MainController;
import Model.Order;
import View.OrderView;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;

public class OrderController {
    private Order orderModel = new Order();
    private OrderView orderView = new OrderView();
    private OrderDao orderDao = new OrderDao();
    MainController mc;
	/* Constructor
	 * The OrderController class is the controller for all things related to SMPS Orders.
	 * it has references to all of the Order GUI elements
	 */
	public OrderController(MainController mainController) {
            mc = mainController;
            //orderModel = new Order(mc.getLoginController().getLoginModel().getEmp());
            
            /*
            * Tell the OrderView that when ever the newOrderB button
            * is clicked to execute the actionPerformed method
            * in the NewORderButtonListener inner class
            */
            orderView.addNewOrderButtonListener(new NewOrderButtonListener());
	}
        
        public class NewOrderButtonListener implements ActionListener{
            public void actionPerformed(ActionEvent e) {
               JOptionPane.showMessageDialog(null, "NewOrderB clicked, OrderController");
               //create a new order!! yapılacak
            }
        }
	
	/*
	 * Besides being aware of these GUI elements, 
	 * the OrderController also handles the Order-related events for the application.
	 * It handles these events through many smaller granular Java Actions, 
	 * with one such action being named AddOrderAction, 
	 * so you'll also find code like this in the OrderController class:
	 * 		// declare it at the top of the class
	 * 		AddProcessAction addProcessAction;
	 * and this:
	 * 		// instantiate it later on
	 * 		addProcessAction = new AddProcessAction(this);
	 * This action listens to the "Add Order" button,
	 * and is triggered whenever the employee presses that button.
	 * in turn, this action calls back to the OrderController and says something like, 
	 * "Hey, we just got an 'Add Order' action, and you need to deal with it.
	 * " The OrderController receives that event, 
	 * and invokes a Java method named startAddOrderAction, 
	 * which in this case means that it constructs and displays a the EditOrderDialog (in 'add' mode).
	 * 
	 */

    public OrderView getOrderView() {
        return orderView;
    }

}
